﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using UAXInversionesWeb.logicaNegocio;

namespace UAXInversionesWeb.supervisor
{
    public partial class InformeAccionesVendidas : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Calendar1_SelectionChanged(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["identificador"] != null)
            {
                String fecha = calendario.SelectedDate.ToString("yyyyMMdd");
                Acciones[] a = Proxy.obtenerInformeAccionesVendidas(fecha);
                if (a.Length > 0)
                {
                    mensaje.Text = "";
                    TableRow row;
                    TableCell cell, cell2, cell3, cell4;

                    for (int i = 0; i < a.Length; i++)
                    {
                        if(a[i].getTipoOperacion()=='V')
                        {
                            row = new TableRow();
                            if (i % 2 != 0)
                            {
                                row.BackColor = System.Drawing.Color.FromArgb(240, 244, 247);
                            }

                            cell = new TableCell();
                            cell.HorizontalAlign = HorizontalAlign.Left;
                            cell.Text = a[i].getIdCliente().ToString();
                            row.Cells.Add(cell);

                            cell2 = new TableCell();
                            cell2.Text = a[i].getEmpresaCotizante();
                            row.Cells.Add(cell2);

                            cell3 = new TableCell();
                            cell3.HorizontalAlign = HorizontalAlign.Right;
                            cell3.Text = a[i].getNumeroDeAcciones().ToString();
                            row.Cells.Add(cell3);

                            cell4 = new TableCell();
                            cell4.HorizontalAlign = HorizontalAlign.Right;
                            cell4.Text = a[i].getValor().ToString("N") + " €";
                            row.Cells.Add(cell4);
                            Table1.Rows.Add(row);
                        }
                    }
                }
                else
                {
                    mensaje.Text = "No hay datos";
                }
            }
        }
    }
}
